﻿using Microsoft.EntityFrameworkCore;
using Microsoft.EntityFrameworkCore.Metadata.Builders;
using PMS.Data.DbUtils.DataMapping;
using PMS.Data.Entities.Common;

namespace PMS.Data.EntityMap.Common
{
    /// <summary>
    /// Represents a GenericAttribute mapping configuration
    /// </summary>
    public partial class GenericAttributeMap : PMSEntityTypeConfiguration<GenericAttribute>
    {
        #region Methods

        /// <summary>
        /// Configures the entity
        /// </summary>
        /// <param name="builder">The builder to be used to configure the entity</param>
        public override void Configure(EntityTypeBuilder<GenericAttribute> builder)
        {
            builder.ToTable("bus_genericattribute");
            builder.HasKey(attribute => attribute.Id);

            builder.Property(attribute => attribute.KeyGroup).HasMaxLength(200).IsRequired();
            builder.Property(attribute => attribute.Key).HasMaxLength(200).IsRequired();
            builder.Property(attribute => attribute.Value).HasMaxLength(500).IsRequired();
            builder.Ignore(attribute => attribute.IsActive);
            base.Configure(builder);
        }

        #endregion
    }
}
